<template>
  <a-drawer :title="`运路由`" width="50%" :visible="visible"
            hide-cancel
            @cancel="visible = false"
            :footer="false"
            v-if="visible">
    <ma-crud ref="crudRef" :columns="columns" :options="options">
    </ma-crud>
  </a-drawer>
</template>
<script setup>
import {computed, inject, ref,watch,reactive} from "vue";
import route from '@/api/routes/route'
const crudRef = ref()
const visible = ref(false)
const waybill_id = ref(0)
const onShow = (id)=>{
  visible.value = true
  waybill_id.value = id
  // crudRef.requestData()
}
let options = ref({
      id: 'ShipmentRouteListInfo',
      pk: 'id',
      rowSelection: {showCheckedAll: true},
      pageLayout: 'fixed',
      // 默认统一设置列宽度
      columnWidth: 0,
      autoRequest: true,
      tableLayoutFixed: true,
      api: route.getList,
      operationColumn: true,
      operationColumnAlign: 'center',
      operationColumnWidth: 120,
      beforeRequest: (requestParams) => {
        requestParams.about_id = waybill_id.value
      },
      beforeAdd: (formData) => {
        formData.about_type = 'App\\Document\\Model\\Waybill'
        formData.ids = [waybill_id.value]
        return true
      },
      add: {
        show: true,
        api: route.save,
        auth: ['routes:route:save']
      },
      edit: {
        show: true,
        api: route.update,
        auth: ['routes:route:update']
      },
      delete: {
        show: true,
        api: route.deletes,
        auth: ['routes:route:delete'],
      },
    })
const columns = reactive([
{
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
  },
  {
    title: "时间",
    dataIndex: "time",
    formType: "date",
    showTime: true
  },
  {
    title: "描述",
    dataIndex: "remark",
    formType: "input",
  }
])
defineExpose({onShow})
</script>